package easy;

/**
 * @author admin
 * 1518. 换酒问题
 * 解题思路：定义一个变量来表示当前酒瓶数，初始值为numBottles，while循环，条件是当前
 * 酒瓶数大于等于交换数;每交换一次酒将当前酒瓶数减去一个numExchange并加1，变量count
 * 也加一，指的是兑换的酒，因此每减去numExchange次，即可获得一瓶新酒，最后返回初始酒
 * 瓶数加上count的总和
 */
public class LeeCode1518 {

    public int numWaterBottles(int numBottles, int numExchange) {
        int count = 0;
        int curBottles = numBottles;
        while(curBottles >= numExchange){
            curBottles = curBottles - numExchange + 1;
            count++;
        }
        return count + numBottles;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode1518().numWaterBottles(15, 4));
    }
}
